import { get } from '@/utils/request';

export interface AuditLog {
  id: string;
  tenantId: string | null;
  userId: string;
  action: string;
  resource: string;
  resourceId: string | null;
  detail: string | null;
  ip: string;
  userAgent: string | null;
  status: 'success' | 'failed';
  errorMessage: string | null;
  createdAt: string;
  user?: {
    id: string;
    firstName?: string;
    lastName?: string;
    email: string;
  };
}

export interface AuditLogListParams {
  page?: number;
  pageSize?: number;
  userId?: string;
  action?: string;
  resource?: string;
  status?: 'success' | 'failed';
  startTime?: string;
  endTime?: string;
}

/**
 * 获取操作日志列表
 */
export const getAuditLogs = (params: AuditLogListParams) => {
  return get<{ list: AuditLog[]; total: number; page: number; pageSize: number }>(
    '/audit-logs',
    params
  );
};

/**
 * 获取操作日志详情
 */
export const getAuditLogById = (id: string) => {
  return get<AuditLog>(`/audit-logs/${id}`);
};

